//************************************************************************
/// <copyrigth>2024-2025 Corporation.All Rights Reserved</copyrigth>
/// <author>tangyingzhong</author>
/// <contact>tangyz114987@outlook.com</contact>
/// <version>v1.0.0</version>
/// <describe>
/// Cross-Platform zip
///</describe>
/// <date>2024/3/10</date>
///***********************************************************************
#ifndef ZIP_H
#define ZIP_H

#include <functional>
#include <memory>
#include <iostream>
#include <vector>
#include <string>
#include "ModuleLoader/ModuleConfig.h"

namespace SystemTool
{
    class CLASS_ITEM Zip
    {
    public:
        // Compress file
        static bool Compress(std::string strFileOrDirPath, std::string &strZipFilePath, bool bIsBigFile = false);

        // Compress stream
        static bool Compress(std::string strFileOrDirPath, std::ostream& os, bool bIsBigFile = false);

        // Compress several files or directory
        static bool Compress(std::vector<std::string>& vFileTable, std::string &strZipFilePath, bool bIsBigFile = false);

        // Compress several files or directory
        static bool Compress(std::vector<std::string>& vFileTable, std::ostream& os, bool bIsBigFile = false);

        // Decompress file/directory
        static bool DeCompress(std::string strZipFilePath, std::string &strTargetDirPath);

        // Decompress stream
        static bool DeCompress(std::istream& is, std::string &strTargetDirPath);

        // Decompress single file in zip only
        static bool DecompressSingleFile(std::string& strZipFilePath, std::string& strFileInZip, std::string &strTargetDirPath);

        // Find file in zip
        static bool FindFileInZip(std::string strZipFilePath, std::string &strFilePathInZip);

        // Rename file in zip
        static bool RenameFileInZip(std::string strZipFilePath, std::string &strFilePathInZip, std::string &strNewFilePathInZip);

        // Add new file to zip
        static bool AddFileToZip(std::string strZipFilePath, std::string &strFilePathInZip, std::string &strLocalFilePath);

        // Delete file in zip
        static bool DeleteFileInZip(std::string strZipFilePath, std::string &strFilePathInZip);

        // Replace file in zip
        static bool ReplaceFileContentInZip(std::string strZipFilePath, std::string &strFilePathInZip, std::string &strLocalFilePath);

        // Get zip file's info
        static bool GetZipInfo(std::string strZipFilePath,
                               int &iZipMajorVersion,
                               int &iZipMinorVersion,
                               int &iCompressMethod,
                               int& iCompressLevel,
                               int& iCrc,
                               bool &bIsEncrypted,
                               int &iLastModifyTime_Ms,
                               int &iCompressedSize,
                               int &iUnCompressedSize,
                               std::string &strFileName);
    };
}
#endif // ZIP_H
